package com.xl.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: zro
 * @Date: 2019/1/8 22:42
 * @Description:
 */
@Controller
public class IndexController {

    private static final String HELLO_WORLD = "Hello World";

    @ResponseBody
    @RequestMapping("/adc")
    public String adc(){
        System.out.println(IndexController.HELLO_WORLD);
        return IndexController.HELLO_WORLD;
    }

    @ResponseBody
    @RequestMapping(value = "/sessions", method = RequestMethod.GET)
    public Object sessions (HttpServletRequest request){
        Map<String, Object> map = new HashMap<>();
        map.put("sessionId", request.getSession().getId());
        map.put("message", request.getSession().getAttribute("map"));
        return map;
    }

}
